unit uConfigImpr;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, ACBrECF, Vcl.StdCtrls, System.TypInfo,
  Vcl.DBCtrls, Data.DB, Vcl.Mask, Vcl.Buttons;

type
  TfrmConfigImpr = class(TForm)
    Label1: TLabel;
    Label4: TLabel;
    dsTblcif: TDataSource;
    dbcbxModelo: TDBComboBox;
    DBComboBox1: TDBComboBox;
    GroupBox1: TGroupBox;
    DBCheckBox1: TDBCheckBox;
    Label2: TLabel;
    btnOk: TBitBtn;
    btnCancelar: TBitBtn;
    btnTeste: TBitBtn;
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure btnOkClick(Sender: TObject);
    procedure btnTesteClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmConfigImpr: TfrmConfigImpr;

implementation

{$R *.dfm}

uses uConexao, uDadosImpr, uPrincipal;

procedure TfrmConfigImpr.btnOkClick(Sender: TObject);
begin
  try
    dmDadosImpr.SalvarManutencao;
  except
    on E: Exception do
    begin
      MessageDlg(e.Message, mtError,[mbOK],0);
      ModalResult := mrNone;
    end;
  end;
end;

procedure TfrmConfigImpr.btnTesteClick(Sender: TObject);
begin
  try
    btnTeste.Enabled := false;

    if btnTeste.Caption = 'Teste Ativar' then
    begin
      dmDadosImpr.ConfigurarImpressora;
      dmDadosImpr.AtivarImpressoraFiscal;

      btnTeste.Caption := 'Teste Desativar';
    end
    else
    begin
      dmDadosImpr.DesativarImpressoraFiscal;

      btnTeste.Caption := 'Teste Ativar';
    end;
  finally
    btnTeste.Enabled := true;
  end;
end;

procedure TfrmConfigImpr.FormCreate(Sender: TObject);
var
  i: TACBrECFModelo;
begin
  dbcbxModelo.Items.Clear ;
  For I := Low(TACBrECFModelo) to High(TACBrECFModelo) do
     dbcbxModelo.Items.Add( GetEnumName(TypeInfo(TACBrECFModelo), integer(I) ) ) ;

end;

procedure TfrmConfigImpr.FormShow(Sender: TObject);
begin
  dmDadosImpr.EditarConfig
end;

end.
